package xin.marcher.wind.process.controller.tradeplatform;

import org.springframework.web.bind.annotation.*;
import xin.marcher.wind.process.domain.request.TradePlatformProcessNodeImplRequest;
import xin.marcher.wind.process.domain.request.TradePlatformProcessNodeRequest;
import xin.marcher.wind.process.domain.vo.TradePlatformProcessNodeImplVO;
import xin.marcher.wind.process.domain.vo.TradePlatformProcessNodeVO;
import xin.marcher.wind.process.service.TradePlatformProcessNodeService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 交易平台业务流程节点管理
 *
 * 
 * @version 1.0
 */
@RestController
@RequestMapping("/trade-platform/process-node")
public class TradePlatformProcessNodeController {

    @Resource
    private TradePlatformProcessNodeService tradePlatformProcessNodeService;

    /**
     * 给某个流程新增流程节点定义
     * @param tradePlatformProcessNodeRequest
     * @return
     */
    @PostMapping
    public TradePlatformProcessNodeVO addProcessNode(@RequestBody TradePlatformProcessNodeRequest tradePlatformProcessNodeRequest) {
        return tradePlatformProcessNodeService.addProcessNode(tradePlatformProcessNodeRequest);
    }

    /**
     * 编辑某个流程节点定义
     * @param id 流程节点ID
     * @param tradePlatformProcessNodeRequest
     * @return
     */
    @PutMapping("/{id}")
    public TradePlatformProcessNodeVO editProcessNode(@PathVariable("id") Long id,  @RequestBody TradePlatformProcessNodeRequest tradePlatformProcessNodeRequest) {
        return tradePlatformProcessNodeService.editProcessNode(id, tradePlatformProcessNodeRequest);
    }

    /**
     * 查看某个流程下的流程节点定义
     * @return
     */
    @GetMapping("/{processId}")
    public List<TradePlatformProcessNodeVO> listProcessNode(@PathVariable("processId")  Long processId) {
        return tradePlatformProcessNodeService.listProcessNode(processId);
    }

    /**
     * 删除某个流程下的流程节点定义
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public Boolean removeProcessNode(@PathVariable("id") Long id) {
        return tradePlatformProcessNodeService.removeProcessNode(id);
    }

    /**
     * 流程节点定义增加实现
     * @param tradePlatformProcessNodeImplRequest
     * @return
     */
    @PostMapping("/impl")
    public TradePlatformProcessNodeImplVO addProcessNodeImpl( @RequestBody TradePlatformProcessNodeImplRequest tradePlatformProcessNodeImplRequest) {
        return tradePlatformProcessNodeService.addProcessNodeImpl(tradePlatformProcessNodeImplRequest);
    }

    /**
     * 编辑流程节点定义实现
     * @param id
     * @param tradePlatformProcessNodeImplRequest
     * @return
     */
    @PutMapping("/impl/{id}")
    public TradePlatformProcessNodeImplVO editProcessNodeImpl(@PathVariable("id") Long id, @RequestBody TradePlatformProcessNodeImplRequest tradePlatformProcessNodeImplRequest) {
        return tradePlatformProcessNodeService.editProcessNodeImpl(id, tradePlatformProcessNodeImplRequest);
    }

    /**
     * 查看流程节点定义的实现
     * @param processNodeId
     * @return
     */
    @GetMapping("/impl/{processNodeId}")
    public List<TradePlatformProcessNodeImplVO> listProcessNodeImpl(@PathVariable("processNodeId") Long processNodeId) {
        return tradePlatformProcessNodeService.listProcessNodeImpl(processNodeId);
    }

    /**
     * 移除流程节点定义下的某个实现
     * @param id
     * @return
     */
    @DeleteMapping("/impl/{id}")
    public Boolean removeProcessNodeImpl(@PathVariable("id") Long id) {
        return tradePlatformProcessNodeService.removeProcessNodeImpl(id);
    }

}